package com.bj58.data.emailreports.sends;

import java.util.Date;
import java.util.List;

import com.bj58.data.emailreports.controllers.FCEmailReportController;
import com.bj58.data.emailreports.model.EmailReportUser;
import com.bj58.data.emailreports.utils.DateUtil;

public class FCSend extends BaseSend{

	
	public static void main(String[] args) {
		FCSend  fs = new FCSend();
		FCEmailReportController  fc = new FCEmailReportController();
		String content="";
		try {
			String searchDate = DateUtil.getStringDate(DateUtil.getDateBefore(new Date(), 1),"yyyy-MM-dd");//查询日期（昨）
			int sendType = 0;  //    2.开天周报
			
			if(null != args && args.length > 0){
				if(args.length != 2){
					System.out.println("params error");
					System.exit(0);
				}
				
				if(args[0].contains("-")){
					searchDate =args[0].trim();
				}
				
				sendType = Integer.parseInt(args[1]);
			}
			
			System.out.println(searchDate);
			System.out.println(sendType);

			
			if(sendType == 2){
				String beginDate = DateUtil.getStringDate(DateUtil.getDateBefore(DateUtil.strToDate(searchDate, "yyyy-MM-dd"), 6),"yyyy-MM-dd");
				String endDate = searchDate;
				content="开天项目周报  from "+ beginDate + " to " + endDate ;
				//开天项目周报
				List<EmailReportUser> userListCpc = fs.getUsersBySendType(41);
				String contextCpc = fc.KTWeekReport(searchDate);
				if("".equals(contextCpc)){
					fs.errorWarn("开天项目周报");
				}else{
					fs.ReportSend(userListCpc, "开天项目周报  from "+ beginDate + " to " + endDate , contextCpc, null);
				}
			}
			
			
		} catch (Exception e) {
			e.printStackTrace();
			fs.errorWarn(content);
		}
	}
}
